package com.jcl.recruit.resume.logic;

import com.jcl.core.utils.CollectionUtils;
import com.jcl.recruit.resume.dao.ResumeProjectDao;
import com.jcl.recruit.resume.model.ResumeProject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName ResumeProjectLogic

 * @Author yyliu
 * @Date 2018/10/31 11:22
 * @Version 1.0
 **/
@Component
public class ResumeProjectLogic {

    @Autowired
    private ResumeProjectDao resumeProjectDao;

    public Map<Integer, List<ResumeProject>> findListByResumeMap(String corpCode, List<Integer> resumeIds) {

        Map<Integer, List<ResumeProject>> dataMap = new HashMap<>();
        List<ResumeProject> list = resumeProjectDao.findListByResumeIds(corpCode, resumeIds);
        if (CollectionUtils.isNotEmpty(list)) {
            for (ResumeProject entity : list) {
                List<ResumeProject> entityList = dataMap.get(entity.getResumeId());
                if (null == entityList) {
                    entityList = new ArrayList<>();
                    dataMap.put(entity.getResumeId(), entityList);
                }
                entityList.add(entity);
            }
        }
        return dataMap;
    }

    public List<ResumeProject> findListByResumeIds(String corpCode, List<Integer> resumeIds) {
        return resumeProjectDao.findListByResumeIds(corpCode, resumeIds);
    }

    public List<ResumeProject> findListByResumeId(String corpCode, Integer resumeId) {
        return resumeProjectDao.findListByResumeId(corpCode, resumeId);
    }

    public List<Map<String, Object>> findObjListByResumeId(String corpCode, Integer resumeId) {
        return resumeProjectDao.findObjListByResumeId(corpCode, resumeId);
    }

    public int isExitEntity(ResumeProject entity) {
        return resumeProjectDao.isExitEntity(entity);
    }

    public int batchInsert(List<ResumeProject> list) {
        return resumeProjectDao.batchInsert(list);
    }

    public int insert(ResumeProject entity) {
        return resumeProjectDao.insert(entity);
    }

    public int updateByPrimaryKey(ResumeProject entity) {
        return resumeProjectDao.updateByPrimaryKey(entity);
    }

    public int deleteById(Integer id) {
        return resumeProjectDao.deleteById(id);
    }

    public int batchDeleteByResumeIds(String corpCode, List<Integer> resumeIds) {
        return resumeProjectDao.batchDeleteByResumeIds(corpCode, resumeIds);
    }
}
